﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using Sac.Web;

public partial class Admin_RootAndPowerManage : System.Web.UI.Page
{
    MenuTreeOperate rootClass = new MenuTreeOperate();

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            //CreateTreeMenu();
            int[] i = {1,4,9,2,6,3 };
            Array.Sort(i);
        }
    }

    /// <summary>
    /// 创建菜单树
    /// </summary>
    private void CreateTreeMenu()
    {
        DataTable dtMenuList = rootClass.GetAllMenuNode();
        treeMenuPower.Nodes.Clear();
        InitTree(treeMenuPower.Nodes, "-1", dtMenuList);
    }

    /// <summary>
    /// 初始化菜单树
    /// </summary>
    /// <param name="treeNodes"></param>
    /// <param name="fartherId"></param>
    /// <param name="dtAllMenuNode"></param>
    protected void InitTree(TreeNodeCollection treeNodes, string fartherId, DataTable dtAllMenuNode)
    {
        DataView dv = new DataView();
        dv.Table = dtAllMenuNode;
        dv.RowFilter = "fartherid=" + fartherId;
        foreach (DataRowView drv in dv)
        {
            TreeNode node = new TreeNode();
            node.Value = drv["ID_KEY"].ToString();
            node.Text = drv["MENU_NAME"].ToString();
            node.SelectAction = TreeNodeSelectAction.SelectExpand;
            treeNodes.Add(node);
            InitTree(node.ChildNodes, node.Value, dtAllMenuNode);
        }
    }

    protected void btnSure_Click(object sender, EventArgs e)
    {

    }
    protected void btnCancel_Click(object sender, EventArgs e)
    {

    }
}
